import {handleActions} from 'redux-actions';

import { UPLOAD_LIST_QUERY, UPLOAD_DETAIL_QUERY } from '../actions/ActionTypes.js'

const upload = handleActions({
  [UPLOAD_LIST_QUERY.REQUEST](state) {
    return {...state, loading: true,};
  },
  [UPLOAD_LIST_QUERY.SUCCESS](state, action) {
    return {...state, uploads: action.payload, loading: false,};
  },
  [UPLOAD_LIST_QUERY.FAILURE](state, action) {
    return {...state, err: action.err, loading: false,};
  },
  [UPLOAD_DETAIL_QUERY.REQUEST](state) {
    return {...state, loading: true,};
  },
  [UPLOAD_DETAIL_QUERY.SUCCESS](state, action) {
    return {...state, uploadDetails: action.payload, loading: false,};
  },
  [UPLOAD_DETAIL_QUERY.FAILURE](state, action) {
    return {...state, err: action.err, loading: false,};
  },
}, {
  loading:false,
  uploadDetails:[]
});

export default upload;
